#!/bin/bash -e

function info() {
echo Usage: `basename $0` '[-r] beta_test'
exit 1
}

while getopts  ":p:f:r" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
        r) ref=true;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

ref=${ref:=false}

if $ref; then
    cut -f2  $1|sed 1d >$out_prefix.beta1
    x=`sed -n '$=' $out_prefix.beta1`
    qual=''
    for i in `seq $x`; do qual="#"$qual; done
    
    awk 'BEGIN{ORS=""}{print}END{print "\n"}' $out_prefix.beta1|sed "i\@test $1
    a\+
    a\\$qual" > $out_prefix.beta.fq
    rm $out_prefix.beta1

else

# beta_actg.py 

cut -f1 $1 |sed 1d |awk '{print ">" $0 "_" NR}' > $out_prefix.fa_id

cut -f2- $1 |sed '1d; s/\t//g' > $out_prefix.atcg

paste $out_prefix.fa_id $out_prefix.atcg |awk 'BEGIN{RS="\t"}{print}' > $out_prefix.beta.fa

rm $out_prefix.fa_id $out_prefix.atcg

fi

. $cmd_done
    